# Create your models here.
from django.db import models
from django.contrib.auth.models import AbstractUser
from django.utils import timezone
from tinymce.models import HTMLField


class TUser(AbstractUser):  # 用户模型
    status = (
        ('male', '男'),
        ('female', '女')
    )
    username = models.CharField(max_length=60, unique=True, null=True)
    password = models.CharField(max_length=128)
    sex = models.CharField(max_length=6, choices=status, default='male', null=True)

    class Meta:
        db_table = 'tuser'


class Project(models.Model):  # 项目管理
    project_name = models.CharField(max_length=60, unique=True, null=True, verbose_name="项目名称")
    Project_Info = models.CharField(max_length=60, blank=True, null=True, verbose_name="项目详情")

    class Meta:
        db_table = "project"


class Rscu(models.Model):  # Rscu管理
    rscu_sn = models.CharField(max_length=60, blank=True, null=True, unique=True, verbose_name="序列号")
    unit_IP = models.CharField(max_length=60, blank=True,null=True,verbose_name="设备IP")
    unit_type = models.CharField(max_length=100, blank=True, null=True, verbose_name="设备型号")
    install_path = models.CharField(max_length=60, blank=True, null=True, verbose_name="安装位置")
    road_id = models.IntegerField(blank=True, null=True, verbose_name="路口ID")
    longitude = models.CharField(max_length=100, null=True, blank=True, verbose_name="经度")
    latitude = models.CharField(max_length=100, null=True, blank=True, verbose_name="纬度")
    project = models.ForeignKey(Project, models.CASCADE)

    class Meta:
        db_table = 'Rscu'


class Camera(models.Model):  # 相机管理
    camera_sn = models.CharField(max_length=60, blank=True, null=True, unique=True, verbose_name="序列号")
    unit_IP = models.CharField(max_length=60, blank=True,null=True,verbose_name="设备IP")
    unit_type = models.CharField(max_length=100, blank=True, null=True, verbose_name="设备型号")
    install_path = models.CharField(max_length=60, blank=True, null=True, verbose_name="安装位置")
    road_id = models.IntegerField(blank=True, null=True, verbose_name="路口ID")
    longitude = models.CharField(max_length=100, null=True, blank=True, verbose_name="经度")
    latitude = models.CharField(max_length=100, null=True, blank=True, verbose_name="纬度")
    project = models.ForeignKey(Project, models.CASCADE)

    class Meta:
        db_table = 'Camera'


class Rsu(models.Model):  # Rsu管理
    rsu_sn = models.CharField(max_length=60, blank=True, null=True, unique=True, verbose_name="序列号")
    unit_IP = models.CharField(max_length=60, blank=True,null=True,verbose_name="设备IP")
    unit_type = models.CharField(max_length=100, blank=True, null=True, verbose_name="设备型号")
    install_path = models.CharField(max_length=60, blank=True, null=True, verbose_name="安装位置")
    road_id = models.IntegerField(blank=True, null=True, verbose_name="路口ID")
    longitude = models.CharField(max_length=100, null=True, blank=True, verbose_name="经度")
    latitude = models.CharField(max_length=100, null=True, blank=True, verbose_name="纬度")
    project = models.ForeignKey(Project, models.CASCADE)

    class Meta:
        db_table = 'Rsu'


class Radar(models.Model):  # 雷达管理
    radar_sn = models.CharField(max_length=60, blank=True, null=True, unique=True, verbose_name="序列号")
    unit_IP = models.CharField(max_length=60, blank=True,null=True,verbose_name="设备IP")
    unit_type = models.CharField(max_length=100, blank=True, null=True, verbose_name="设备型号")
    install_path = models.CharField(max_length=60, blank=True, null=True, verbose_name="安装位置")
    road_id = models.IntegerField(blank=True, null=True, verbose_name="路口ID")
    longitude = models.CharField(max_length=100, null=True, blank=True, verbose_name="经度")
    latitude = models.CharField(max_length=100, null=True, blank=True, verbose_name="纬度")
    project = models.ForeignKey(Project, models.CASCADE)

    class Meta:
        db_table = 'Radar'
